<template>
  <div>
    <!--用户信息-->
    <el-row type="flex" justify="space-between">
      <el-col :span="4"></el-col>
      <el-col :span="13">
        <user-info></user-info>
      </el-col>
      <el-col :span="4"></el-col>
    </el-row>
    <!--用户详情-->
    <el-row :gutter="20" type="flex" justify="center" style="margin-top: 30px">
      <el-col :span="3">
        <!--详情菜单-->
        <user-center-menu></user-center-menu>
      </el-col>
      <el-col :span="10">
        <!--详情内容-->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import userInfo from '@/components/user/userCenterUserInfo'
import userCenterMenu from '@/components/user/userCenterMenu'
import { mapMutations } from 'vuex'

export default {
  data () {
    return {
      params: {}
    }
  },
  created () {
    this.loadUserInfo()
  },
  // DOM对象加载完成时
  mounted () {},
  methods: {
    ...mapMutations('userCenter', { setUserInfo: 'setUserInfo' }),
    async loadUserInfo (context, params) {
      const url = this.$config.urls.get('load_user_info')
      const { data: res } = await this.$http.post(url)
      if (res.code !== 0) {
        this.$message.error('用户未登录！')
        console.log(res)
      } else {
        // console.log(res.data)
        this.setUserInfo(res.data)
      }
    }
  },
  computed: {},
  components: { userInfo, userCenterMenu },
  name: 'userCenter'
}
</script>

<style lang="less" scoped>
.el-menu {
  border-right: none;
}
.svg-icon {
  width: 24px !important;
  color: #999999;
}
.el-main {
  padding: 0;
}
</style>
